<template>
  <div id="list">
  	<ul style="padding-left:5px;">
  		<li v-for="item in admins" :key="item.adminId" :class="{ active: currentSession ? item.username === currentSession.username : ''}" v-on:click="changeCurrentSession(item)">
  			<img class="avatar" :src="item.userFace" :alt="item.name">
            
            <p class="name">{{item.name}}</p>
            <el-badge :is-dot="dot ? dot[`${currentAdmin.username}#${item.username}`] : false" style="margin-left:8px;" class="item">
            </el-badge>
  		</li>
  	</ul>
  </div>
</template>

<script>
import {mapState} from 'vuex'

export default {
  name: 'list',
  data () {
    return {
      
    }
  },
  computed: mapState([
        'dot',
        'admins',
        'currentAdmin',
        'currentSession'
	]),
  methods:{
  	changeCurrentSession:function (data) {
  		this.$store.commit('changeCurrentSession',data)
  	}
  }
}
</script>

<style scoped>
li {
    padding: 0;
    border-bottom: 1px solid #292C33;
    cursor: pointer;
    list-style-type:none;
}

li.active {/*注意这个是.不是冒号:*/
    background-color: rgba(255, 255, 255, 0.1);
}

.avatar {
    border-radius: 2px;
    width: 30px;
    height: 30px;
    vertical-align: middle;
}

.name {
    display: inline-block;
    margin-left: 15px;
}
li:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

</style>
